{include file="pub:header"/}
<script type="text/javascript">
$(function(){
	$('.J_tablelist').listTable();
});
function setSort() {
	$('#myform').attr('action', "{:url('gcatsort')}");
	ajaxpost('myform');
}
function setStatus(id, status) {
	if(!id || id.length == 0)return alert("请选择一条记录");

	$('#myform').attr('action', "{:url('gcatstate')}");
	$('#state').val(status);
	ajaxpost('myform');
}
function editConfig(id){
  art.dialog.open('{:url('gcatedit')}?id='+id,{title:'类型编辑',id:'cats',width:550,height:350,lock: true,fixed:true,close:function(){location.reload(true);}});
}
</script>
</head>
<body>


	<div class="subnav">
		<div class="content_menu ib_a blue line_x">
            <a href="javascript:;"><span class="pagetitle">【商品类型】</span></a>
            <span>|</span>
			<a class="add fb J_showdialog" href="javascript:;" onclick="editConfig(0);"><em>添加类型</em></a>
		</div>
	</div>

	<div class="pad_lr_10">

		<form action="{:url('gcatindex')}" method="get" class="form-inline" role="form">

			<table width="100%" cellspacing="0" class="search_form">
				<input type="hidden" name="state" value="{$state}">
				<tbody>
				<tr>
					<td>
						<div class="explain_col">
							名称或标题
							<input name="keywords" type="text" class="input-text" size="30" value="{$keywords}">
							<input type="submit" name="search" class="btn" value="搜索" />
						</div>
					</td>
				</tr>
				</tbody>
			</table>

		</form>


      <div class="col_tab" style="margin-top:5px;">
		<ul class="J_tabs tab_grid cu_li">
		   {volist name="reviewary" id="vo"}
		   <li<?php echo $key==$state?' class="current"':'' ?>><a href="gcatindex?state={$key}">{$vo}</a></li>
		   {/volist}
		</ul>


		  <div class="J_tablelist table_list">

			  <table width="100%" cellspacing="0">

				  <thead>
				  <tr>
					  <th width="40"><input type="checkbox" name="checkall" class="J_checkall"></th>
					  <th class="sort_th">编号</th>
					  <th align="left" class="sort_th">类型名称</th>
					  <th class="sort_th">状态</th>
					  <th class="sort_th">排序</th>
					  <th>操作</th>
				  </tr>
				  </thead>

				  <form action="" id="myform">
					  <input type="hidden" name="state" value="1" id="state">
					  <tbody>
					  {volist name="list" id="vo"}
						  <tr>
							  <td align="center"><input type="checkbox" name='id[]' class="J_checkitem" value="{$vo['id']}"></td>
							  <td align="center">{$vo['id']}</td>
							  <td>{$vo['name']}</td>
							  <td align="center"><?php echo 1==$vo['state']?"<font color='green'>启用</font>":"<font color='red'>禁用</font>";?></td>
							  <td align="center">
								  <input type="text" name="sort[{$vo['id']}]" style="text-align: center;" class="input-text" size="8" value="{$vo['sort']}">
							  </td>
							  <td align="center">
								  【<a href="javascript:void(0);" onclick="editConfig({$vo['id']})" title="点击修改">修改</a>】
								  <?php if(1==$vo['state']){ ?>
								  【<a href="javascript:;" onclick="ajaxurl('{:url('gcatstate',array('id'=>$vo['id'],'state'=>0))}');" title="点击禁用">禁用</a>】
								  <?php }else{ ?>
								  【<a href="javascript:;" onclick="ajaxurl('{:url('gcatstate',array('id'=>$vo['id'],'state'=>1))}');" title="点击启用"><font color="red">启用</font></a>】
								  <?php } ?>
								  【<a href="javascript:;" onclick="ajaxget('{:url('gcatdel',array('id'=>$vo['id']))}','确认要删除? 删除后不可恢复 ！')" title="点击删除">删除</a>】
							  </td>
						  </tr>
					  {/volist}

					  {empty name="list"}
						  <tr>
							  <td colspan="6" align="center">暂无数据 !</td>
						  </tr>
					  {/empty}

					  </tbody>
				  </form>

			  </table>

		  </div>

		</div>


		<div class="btn_wrap_fixed">
		    <label class="select_all mr10"><input type="checkbox" name="checkall" class="J_checkall">全选/取消</label>
            <input type="button" value="批量启用" class="btn" onclick="setStatus($.checkBoxValue('id[]'), 1)"/>
            <input type="button" value="批量禁用" class="btn" onclick="setStatus($.checkBoxValue('id[]'), 0)"/>
            <input type="button" class="btn" onclick="setSort();" value="排序" />
			<div id="pages">{$page}</div>
		</div>

    </div>

{include file="pub:footer" /}
